/*
 * CRtpSound.h
 *
 *  Created on: 2018年8月27日
 *      Author: zhengboyuan
 */

#ifndef CRTPSOUND_H_
#define CRTPSOUND_H_

#include "RtpSound.h"
#include "UdpRtpSocket.h"
#include "AudioDevice.h"
#include "SharedPtr.h"
#include "TThread.h"
#include "ByteBuffer.h"


class CRtpSound : public comn::Thread
{
public:
    CRtpSound();
    virtual ~CRtpSound();

    int open(int port, int codec, int channels, int samplerate);

    void close();

	float getVolume();

    void setVolume(float volume);


protected:
    virtual int run();
    virtual void doStop();

protected:
    typedef std::shared_ptr< av::AudioDevice >      AudioDevicePtr;

    void handleRecvRtpPacket(av::RtpPacket& packet);

    void onRecvPacket(av::MediaPacket& pkt);

protected:
    av::UdpRtpSocket    m_socket;
    AudioDevicePtr  m_device;
    int     m_codec;
    std::shared_ptr< av::RtpUnPacker >  m_rtpUnPacker;

    ByteBuffer  m_buffer;
    int64_t m_pts;

};

#endif /* CRTPSOUND_H_ */
